package com;

import java.awt.Color;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.LinkedList;

public class ChessArray {
	private PropertyChangeSupport propertyChangeSupport;
	private static ChessArray ca;
	private Color[][] chessAraay;
	LinkedList<Chess> chessStack;
	public ChessArray() {
		propertyChangeSupport=new PropertyChangeSupport(this);
		chessAraay=new Color[15][15];
		chessStack=new LinkedList<Chess>();
		ca=this;
	}	
	 
	public static ChessArray getInstance(){
		if(ca==null){
			ca=new ChessArray();
		}
		return ca;
	}
	
	public void setChess(Chess chess){
		chessAraay[chess.getI()][chess.getJ()]=chess.getColor();
		chessStack.push(chess);
		propertyChangeSupport.firePropertyChange("chessArray", null, chess);
	}
	
	
	public Color getChess(int i,int j){
		return chessAraay[i][j];
	}
	
	
	public void addPropChangeListener(PropertyChangeListener listener){
		propertyChangeSupport.addPropertyChangeListener(listener);
	}
	
	public void clear(){
		for(int i=0;i<15;i++)
			for(int j=0;j<15;j++){
				chessAraay[i][j]=null;
			}
	}
}
